#include <stdio.h>
#include <stdlib.h>

typedef struct TreeNode
{

    char data ;

    struct TreeNode* left ;

    struct TreeNode* right ;  

} TreeNode , *PTreeNode ;

PTreeNode BuyNode (char x)
{

    PTreeNode newnode = (PTreeNode) malloc (sizeof (TreeNode)) ;

    if (newnode == NULL)
    {

        perror ("malloc fail!") ;

        exit (1) ;

    }

    newnode -> data = x ;

    newnode -> left = newnode -> right = NULL ;

    return newnode ;

}

PTreeNode CreateTreeByprevOrder (char* arr , int* i)
{

    if (arr [*i] == '#')
    {

        (*i)++ ;

        return NULL ;

    }

    PTreeNode root = BuyNode (arr [i]) ;

    (*i)++ ;

    root -> left = CreateTreeByprevOrder (arr , i) ;

    root -> right = CreateTreeByprevOrder (arr , i) ;

    return root ;

}

void inOrder (PTreeNode root)
{

    if (root == NULL)
    {

        return ;

    }

    inOrder (root -> left) ;

    printf ("%c " , root -> data) ;

    inOrder (root -> right) ;
    
}

int main ()
{

    char arr [100] ;

    scanf ("%s" , arr) ;

    int i = 0 ;

    PTreeNode root = CreateTreeByprevOrder (arr , &i) ;

    inOrder (root) ;

    return 0 ;

}